/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin			*/
/*	Project:	GlbCloud			*/
/*	Author:		gong_libin			*/
/*	Date:		2012_01_12			*/
/*	File:		MrHash.h			*/
/********************************************************/

#ifndef _MRHASH_H
#define	_MRHASH_H

#include "MrShm.h"
#include <ctype.h>

#define	MR_PLUS				12345
#define	MR_MASK				0x7FFFFFFF
#define	MR_BASIC			0x238F13AF
#define	MR_OFFSET			1103515243

/*static const ULONG sg_ulBucket[] = {
  5ul,          7ul,        53ul,         97ul,         193ul,
  389ul,       769ul,       1543ul,       3079ul,       6151ul,
  12289ul,     24593ul,     49157ul,      98317ul,      196613ul,
  393241ul,    786433ul,    1572869ul,    3145739ul,    6291469ul,
  12582917ul,  25165843ul,  50331653ul,   100663319ul,  201326611ul,
  402653189ul, 805306457ul, 1610612741ul, 3221225473ul, 4294967291ul
};*/

#define	MR_BUCKET			4294967291ul

class CMrHash : public CMrShm
{
public:
	CMrHash();
	virtual ~CMrHash();

	void MrHashDelete();
	void* MrHashGetBucket(ULONGLONG ullKey);
	int MrHashCreate(key_t iKey, ULONG ulSize);
	void MrHashPutBucket(ULONGLONG ullKey, void** ppKey);
	ULONGLONG MrHashFunction(char* pszKey, UINT uiLength);

private:
	ULONG m_ulHash;

};

#endif /* _MRHASH_H */
